		
	function changeState(tag_id){
		var state = document.getElementById(tag_id).style.display;
		if(state!="block"){
			document.getElementById(tag_id).style.display="block";
		}else{
			document.getElementById(tag_id).style.display="none";
		}
	}
	//userManager
	function userManager(url){
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		xmlhttp.open("POST",url,true);
		xmlhttp.send();
	}
	/**
	 *锁定权限
	 **/
	function locked(currentPage,state,id){
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		var powerURL="power.state="+state+"&power.id="+id;
		xmlhttp.open("POST","/control/mapping/power_locked.go?currentPage="+currentPage+"&"+powerURL,true);
		xmlhttp.send();
	}
	function editPower(currentpage,rowID){
		var currentTD=document.getElementById(rowID).getElementsByTagName("td");
		//编辑用户名
		var name = currentTD[1].innerHTML;
		currentTD[1].innerHTML='<input class="editName" type="text" value="'+name+'" name="power.name">';
		//编辑URL
		var url=currentTD[3].innerHTML;
		currentTD[3].innerHTML='<input class="editURL" type="text" value="'+url+'" name="power.url">';
		//编辑备注
		var remarks=currentTD[4].innerHTML;
		currentTD[4].innerHTML='<textarea  class="editRemarks"  name="power.remarks">'+remarks+'</textarea>';
		//OK
		var remarks=currentTD[5].innerHTML;
		currentTD[5].innerHTML='<input type="image" src="/image/admin/ok.gif" onclick="savePower('+currentpage+',\''+rowID+'\')"/>';
	}
	function editRole(maxRecord,currentpage,rowID){
		var currentTD=document.getElementById(rowID).getElementsByTagName("td");
		//编辑用户名
		var name = currentTD[1].innerHTML;
		currentTD[1].innerHTML='<input class="editName" type="text" value="'+name+'" name="role.name">';
		//角色备注
		var remarks=currentTD[3].innerHTML;
		currentTD[3].innerHTML='<textarea  class="editRemarks"  name="role.remarks">'+remarks+'</textarea>';
		//OK
		currentTD[5].innerHTML='<input type="image" src="/image/admin/ok.gif" onclick="saveRole('+maxRecord+','+currentpage+',\''+rowID+'\')"/>';
	}
	function editAdmin(rowID,maxRecord,currentpage){
		var currentTD=document.getElementById(rowID).getElementsByTagName("td");
		//编辑用户名
		var name = currentTD[1].innerHTML;
		currentTD[1].innerHTML='<input class="editName" type="text" value="'+name+'" name="admin.name">';
		//编辑用户名
		var email = currentTD[2].innerHTML;
		currentTD[2].innerHTML='<input class="editName" type="text" value="'+email+'" name="admin.email">';
		//编辑用户名
		var phone = currentTD[3].innerHTML;
		currentTD[3].innerHTML='<input class="editName" type="text" value="'+phone+'" name="admin.phone">';
		//角色备注
		var remarks=currentTD[4].innerHTML;
		currentTD[4].innerHTML='<textarea  class="editRemarks"  name="admin.remarks">'+remarks+'</textarea>';
		//OK
		currentTD[8].innerHTML='<input type="image" src="/image/admin/ok.gif" onclick="saveAdmin('+maxRecord+','+currentpage+',\''+rowID+'\')"/>';
	}
	function savePower(currentPage,rowID){
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		
		var powerURL=""
		var currentTD=document.getElementById(rowID).getElementsByTagName("td");
		//ID
		var id = currentTD[0].innerHTML;
		powerURL+="power.id="+id+"";
		//用户名
		var name = currentTD[1].getElementsByTagName('input')[0].value;
		powerURL+="&power.name="+name+"";
		//URL
		var url = currentTD[3].getElementsByTagName('input')[0].value;
		powerURL+="&power.url="+url+"";
		//备注
		var remarks = currentTD[4].getElementsByTagName('textarea')[0].value;
		powerURL+="&power.remarks="+remarks+"";
		powerURL = encodeURI(encodeURI(powerURL));
		//编辑用户名
		xmlhttp.open("POST","/control/mapping/power_editPower.go?currentPage="+currentPage+"&"+powerURL,true);
		xmlhttp.send();
	}
	
	function saveRole(maxRecord,currentpage,rowID){
	
		var roleUrl="maxRecord="+maxRecord+"&currentPage="+currentpage;
		var currentTD=document.getElementById(rowID).getElementsByTagName("td");
		//角色ID
		var id = currentTD[0].innerHTML;
		roleUrl+="&role.id="+id;
		//编辑用户名
		var name = currentTD[1].getElementsByTagName("input")[0].value;
		roleUrl+="&role.name="+name;
		//角色备注
		var remarks=currentTD[3].getElementsByTagName("textarea")[0].value;
		roleUrl+="&role.remarks="+remarks;

		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		//URL转码
		roleUrl = encodeURI(encodeURI(roleUrl));
		xmlhttp.open("POST","/control/mapping/role_editRole.go?"+roleUrl,true);
		xmlhttp.send();
	}
	function saveAdmin(maxRecord,currentpage,rowID){
		var adminUrl="maxRecord="+maxRecord+"&currentPage="+currentpage;
		var currentTD=document.getElementById(rowID).getElementsByTagName("td");
		//角色ID
		var id = currentTD[0].innerHTML;
		adminUrl+="&admin.id="+id;
		//用户名
		var name = currentTD[1].getElementsByTagName("input")[0].value;
		adminUrl+="&admin.name="+name;
		//用户email
		var email = currentTD[2].getElementsByTagName("input")[0].value;
		adminUrl+="&admin.email="+email;
		//用户移动电话
		var phone = currentTD[3].getElementsByTagName("input")[0].value;
		adminUrl+="&admin.phone="+phone;
		//角色备注
		var remarks=currentTD[4].getElementsByTagName("textarea")[0].value;
		adminUrl+="&admin.remarks="+remarks;

		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		//URL转码
		adminUrl = encodeURI(encodeURI(adminUrl));
		
		xmlhttp.open("POST","/control/mapping/admin_editAdmin.go?"+adminUrl,true);
		xmlhttp.send();
	}
	//打开角色列表
	function openRoles(powerid,parent){
		if(parent==0){
			alert("顶级父类不能授权与角色");
			return false;
		}
		var urlpath = "/control/mapping/power_powerForRole.go?power.id="+powerid;
		//
		theWindow = window.open (urlpath,"角色列表","width=550, height=350, scrollbars=yes, left="+(screen.width-550)/2+", top="+(screen.height-350)/2+"");	
	}
	/**
	*权限列表查询
	**/
	function powerList(roleid,roleName){
		var urlpath = "/control/mapping/role_powerList.go?role.id="+roleid+"&role.name="+roleName;
		urlpath = encodeURI(encodeURI(urlpath));
		//
		theWindow = window.open (urlpath,"添加权限角色","width=550, height=350, scrollbars=yes, left="+(screen.width-550)/2+", top="+(screen.height-350)/2+"");	
	
	}
	/**
	*改变用户的角色
	**/
	function changeRole(adminId,adminName){
		var urlpath = "/control/mapping/admin_editAdminForRole.go?admin.id="+adminId+"&admin.name="+adminName;
		urlpath = encodeURI(encodeURI(urlpath));
		//
		theWindow = window.open (urlpath,"修改管理员的角色","width=550, height=350, scrollbars=yes, left="+(screen.width-550)/2+", top="+(screen.height-350)/2+"");	
	}
	/**
	*产寻角色下的所有用户
	**/
	function adminList(roleid,roleName){
		var urlpath = "/control/mapping/role_adminList.go?role.id="+roleid+"&role.name="+roleName;
		urlpath = encodeURI(encodeURI(urlpath));
		//
		theWindow = window.open (urlpath,"操作角色下的用户","width=550, height=350, scrollbars=yes, left="+(screen.width-550)/2+", top="+(screen.height-350)/2+"");	
	}
		//锁定 解锁角色
	function lock(id,state,currentPage,maxRecord){
		var xmlhttp;
		var urlPath="/control/mapping/role_lockRole.go?role.id="+
								id+"&role.state="+state+"&currentPage="+currentPage+"&maxRecord="+maxRecord;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		xmlhttp.open("POST",urlPath,true);
		xmlhttp.send();
	}
	//用户角色、锁定
	function lockAdmin(id,state,currentPage,maxResult){
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		var adminURL="&admin.state="+state+"&admin.id="+id;
		xmlhttp.open("POST","/control/mapping/admin_locked.go?currentPage="+currentPage+"&maxResult="+maxResult+adminURL,true);
		xmlhttp.send();
	}
	/*改变每页显示的大小*/
	function changePageSize(_url,_date,tab){
		_date+="&maxrecord="+tab.value;
		alert(_date);
		changeContent(_url,_date);
	}
	/**
	 * 改变主题的内容
	 * @param _url
	 * @param _date
	 * @return
	 */
	function changeContent(_url,_date){
		$.ajax({
		   type: "POST",
		   url: _url,
		   data: _date,
		   success: function(msg){
		     $("#main_content").html(msg);
		   }
		});
	}
	 /**
	  * div 回调显示区域
	  * form 提交的Form表单
	  * */
	 function ajaxFormSubmit(div,form){
	 	 $(form).ajaxSubmit(function(responseText) { 
	          $(div).html(responseText);
	      }); 
	 }
	 /**
	  * 添加权限
	 **/
	 function addPower(){
		 //名称验证
		 if($.trim($("#_powerName").val()).length<1){
			 $("#nameMassage").css("color","red");
			 return false;
		 }else{
			 $("#nameMassage").css("color","#55AAFF");
		 }
		//名称验证
		 if($.trim($("#power_parent_name").val()).length<1){
			 $("#parentMassage").css("color","red");
			 return false;
		 }else{
			 $("#parentMassage").css("color","#55AAFF");
		 }
		//名称验证
		 if($("#power_parent_id").val()>0 && $.trim($("#_powerUrl").val()).length<1){
			 $("#URLMessage").css("color","red");
			 return false;
		 }else{
			 $("#URLMessage").css("color","#55AAFF");
		 }
		 ajaxFormSubmit("#main_content","#add_power_form");
	 }
	 /*复选框全选或全不选效果*/
function selectAll(){
	if($("#allCheckBox").attr("checked")=="checked"){
		$("input[title='checkedName']").attr("checked", true);
	}else{
		$("input[title='checkedName']").attr("checked", false);
	}
}
function resetAll(){
	$("input[title='checkedName']").attr("checked", false);
}
/**审核通过**/
function pass(){
	$("#type").val(200);
	checkPass();
}
/**拒绝审核**/
function unpass(){
	$("#type").val(300);
	checkPass();
}
function checkPass(){
	var flag=false;
	 var oInput=$('[title="checkedName"]');
	 for(var i=0;i<oInput.length;i++){
		 if(oInput[i].checked==true){
			 flag=true;
			 break;
		 }
	 }
	if(flag){
		 ajaxFormSubmit("#main_content","#update_ad_form");
	}else{
		alert("请选择一项");
	}
}
/*创建静态的HTML*/
function checkForm(form){
	var flag=false;
	 var oInput=$('[title="checkedName"]');
	 for(var i=0;i<oInput.length;i++){
		 if(oInput[i].checked==true){
			 flag=true;
			 break;
		 }
	 }
	if(flag){
		ajaxFormSubmit("#main_content",form);
	}else{
		alert("请选择一项");
	}
}

function changeButtonValue(id,name){
	$("#_selectBook").val("查询"+name+"类别下的书籍");
	$("#setTypeName").val(name);
}
function findTypeBook(page){
	var flag=false;
	var typeid;
	 var oInput=$('input[title="typebook"]');
	 for(var i=0;i<oInput.length;i++){
		 if(oInput[i].checked==true){
			 typeid=oInput[i].value;
			 flag=true;
			 break;
		 }
	 }
	if(flag){
		$.ajax({
			   type: "POST",
			   url: '/control/mapping/book_typeBook.go',
			   data: "page="+page+"&typeId="+typeid+"&ftlName="+$("#ftlName").val(),
			   success: function(msg){
			     $("#type_book_list").html(msg);
			   }
			});
	}else{
		alert("请选择一项");
	}
}
function resetFrom(){
	$("#_selectBook").val("查询类别书籍");
}
//设置模板
function modulSelect(index){
	if(index==1){
		$("#htmlName").val("type_book_1.html");
	}else if(index==2){
		$("#htmlName").val("type_book_2.html");
	}else if(index==3){
		$("#htmlName").val("type_book_3.html");
	}else if(index==4){
		$("#htmlName").val("type_book_4.html");
	}
}
/*检查模板选择*/
function checkModulSelect(){
	var flag=false;
	 var oInput=$('input[title="modul"]');
	 for(var i=0;i<oInput.length;i++){
		 if(oInput[i].checked==true){
			 typeid=oInput[i].value;
			 flag=true;
			 break;
		 }
	 }
	 $("#typeName").val($("#setTypeName").val());
	 if(flag){
		 checkForm("#type_book_from");
	 }else{
		 alert("请选择一个模板")
	 }
}
/**
 * 首页导航
 * @return
 */
function navigation(){
	var flag=false;
	var oInput=$('input[title="bookType"]');
	 for(var i=0;i<oInput.length;i++){
		 if(oInput[i].checked==true){
			 typeid=oInput[i].value;
			 flag=true;
			 break;
		 }
	 }
	 if(flag){
		 ajaxFormSubmit("#main_content","#navigation_form");
	 }else{
		 alert("请选择一项");
	 }
	
}

function sureAuditing(){
	ajaxFormSubmit('#main_content','#auditing_book_form');
	$.closePopupLayer();
}